home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 4925 / 4925.xpi / components / AutopagerCOMP.js < prev   
Text File  |  2010-02-08  |  5KB  |  144 lines

  1. /***********************************************************
  2. constants
  3. ***********************************************************/
  4.  
  5. // reference to the interface defined in nsIAutopagerCOMP.idl
  6. const nsIAutopagerCOMP = Components.interfaces.nsIAutopagerCOMP;
  7.  
  8. // reference to the required base interface that all components must support
  9. const nsISupports = Components.interfaces.nsISupports;
  10.  
  11. const CLASS_ID = Components.ID("{93AFF2EE-79AA-11DD-8660-026156D89593}");
  12.  
  13. // description
  14. const CLASS_NAME = "AutopagerCOMP Javascript XPCOM Component";
  15.  
  16. // textual unique identifier
  17. const CONTRACT_ID = "@www.teesoft.com/AutopagerCOMP;1";
  18.  
  19. /***********************************************************
  20. class definition
  21. ***********************************************************/
  22.  
  23. //class constructor
  24. function AutopagerCOMP() {
  25.         // If you only need to access your component from Javascript, uncomment the following line:
  26.     this.wrappedJSObject = this;
  27. };
  28.  
  29. // class definition
  30. AutopagerCOMP.prototype = {
  31.  
  32.         allSiteSetting: [],
  33.         updateSites: [],
  34.         siteConfirms : [],
  35.         discoverdUrls : [],
  36.         publishingSite : [],
  37.         // define the function we want to expose in our interface
  38.         loadAll: function() {
  39.             return this.allSiteSetting;
  40.         },
  41.         setAll: function(settings) {
  42.             this.allSiteSetting = settings;
  43.         },
  44.   
  45.         getUpdateSites : function() {
  46.             return this.updateSites;
  47.         },
  48.         setUpdateSites : function(sites) {
  49.             this.updateSites = sites;
  50.         },
  51.         getSiteConfirms : function() {
  52.             return this.siteConfirms;
  53.         },
  54.         setSiteConfirms : function(sites) {
  55.             this.siteConfirms = sites;
  56.         },
  57.         getDiscoveredUrls : function()
  58.         {
  59.             return this.discoverdUrls;
  60.         },
  61.         getPublishingSite : function ()
  62.         {
  63.           return this.publishingSite;
  64.         },
  65.         setPublishingSite : function (publishingSite)
  66.         {
  67.           this.publishingSite = publishingSite;
  68.         },
  69.  
  70.         QueryInterface: function(aIID)
  71.         {
  72.                 if (!aIID.equals(nsIAutopagerCOMP) &&
  73.                         !aIID.equals(nsISupports))
  74.                         throw Components.results.NS_ERROR_NO_INTERFACE;
  75.                 return this;
  76.         }
  77. };
  78.  
  79.  
  80. /***********************************************************
  81. class factory
  82.  
  83. This object is a member of the global-scope Components.classes.
  84. It is keyed off of the contract ID. Eg:
  85.  
  86. myAutopagerCOMP = Components.classes["'@www.teesoft.com/AutopagerCOMP;1"].
  87.                           createInstance(Components.interfaces.nsIAutopagerCOMP);
  88.  
  89. ***********************************************************/
  90. var AutopagerCOMPFactory = {
  91.         createInstance: function (aOuter, aIID)
  92.         {
  93.                 if (aOuter != null)
  94.                         throw Components.results.NS_ERROR_NO_AGGREGATION;
  95.                 return (new AutopagerCOMP()).QueryInterface(aIID);
  96.         }
  97. };
  98.  
  99. /***********************************************************
  100. module definition (xpcom registration)
  101. ***********************************************************/
  102. var AutopagerCOMPModule = {
  103.         registerSelf: function(aCompMgr, aFileSpec, aLocation, aType)
  104.         {
  105.                 aCompMgr = aCompMgr.
  106.                 QueryInterface(Components.interfaces.nsIComponentRegistrar);
  107.                 aCompMgr.registerFactoryLocation(CLASS_ID, CLASS_NAME,
  108.                         CONTRACT_ID, aFileSpec, aLocation, aType);
  109.         },
  110.  
  111.         unregisterSelf: function(aCompMgr, aLocation, aType)
  112.         {
  113.                 aCompMgr = aCompMgr.
  114.                 QueryInterface(Components.interfaces.nsIComponentRegistrar);
  115.                 aCompMgr.unregisterFactoryLocation(CLASS_ID, aLocation);
  116.         },
  117.  
  118.         getClassObject: function(aCompMgr, aCID, aIID)
  119.         {
  120.                 if (!aIID.equals(Components.interfaces.nsIFactory))
  121.                         throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
  122.  
  123.                 if (aCID.equals(CLASS_ID))
  124.                         return AutopagerCOMPFactory;
  125.  
  126.                 throw Components.results.NS_ERROR_NO_INTERFACE;
  127.         },
  128.  
  129.         canUnload: function(aCompMgr) {
  130.                 return true;
  131.         }
  132. };
  133.  
  134. /***********************************************************
  135. module initialization
  136.  
  137. When the application registers the component, this function
  138. is called.
  139. ***********************************************************/
  140. function NSGetModule(aCompMgr, aFileSpec) { 
  141.         return AutopagerCOMPModule;
  142. }
  143.  
  144.